package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealAndDishMapper {


    // 根据套餐id删除套餐和菜品的关联数据
    void deleteSetmealDishBySetmealId(List<Long> ids);

    // 批量插入套餐和菜品的关联数据
    //这里不需要@AutoFill
    void insertBatch(List<SetmealDish> setmealDishes);

    // 根据套餐id查询套餐和菜品的关联数据
    @Select("select id, setmeal_id, dish_id, name, price, copies from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getBySetmealId(Long id);

    // 根据套餐id查询菜品数据
    @Select("select  d.name, d.image, d.description," +
            " s.copies from setmeal_dish s left join dish d " +
            " on d.id = s.dish_id where setmeal_id = #{Setmealid} ")
    List<DishItemVO> queryDishById(Long Setmealid);
}
